import xlrd
import pymysql

file = r'C:\Users\Administrator\Desktop\2.xls'

wb = xlrd.open_workbook(file)
ws = wb.sheet_by_name('Sheet1')

list = []

for i in range(ws.nrows):
    for j in range(ws.ncols):
        list.append(ws.cell_value(i,j))
    sql = "INSERT INTO 省总委员表(姓名,性别,单位及职务,身份,所属ID,内部顺序) VALUES ('%s','%s','%s','%s',%d,%d)" \
          % (list[0],list[1],list[2],list[3],list[4],list[5])
    print(sql)
    conn = pymysql.connect("localhost", "root", "password", "contacts", charset='utf8')
    cur = conn.cursor()
    cur.execute(sql)
    conn.commit()
    cur.close()
    conn.close()
    list.clear()